import torch
import torch.nn.functional as F
from torch.autograd import Variable
import matplotlib.pyplot as plt

# 做一些假数据来观看图像
x = torch.linspace(-5, 5, 200)
x = Variable(x)

x_np = x.data.numpy()

y_relu = torch.relu(x).data.numpy()
y_sigmoid = F.sigmoid(x).data.numpy
y_tanh = F.tanh(x).data.numpy
y_softplus = F.softplus(x).data.numpy

plt.subplot(2, 2, 1)
plt.plot(x_np, y_relu, c='red', label='relu')
plt.ylim((-1, 5))
plt.legend(loc='best')


plt.show()
